﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using E.Enum;

namespace E.Web.training.score
{
    public partial class ScoreStatistics : BasePage
    {
        public IList<ShortScoreModel> list;
        //public IDictionary<EnumScoreCategory, string> scoreList;
        public System.Text.StringBuilder sb = new System.Text.StringBuilder();
        public IList<ScoreCategoryModel> scoreList;

        protected override void ShowPage()
        {
            ExamBLL bll = new ExamBLL();
            list = bll.GetUserCourseScoreList(userid);
            //scoreList = EnumClass.GetScoreCategoryList();
            scoreList = bll.GetScoreCategoryList();

            foreach (ScoreCategoryModel model in scoreList)
            {
                sb.Append("<div class=\"s_rows\">\r\n");
                sb.Append("  <div class=\"s_r_sc\">" + model.Name + "</div>\r\n");

                if (model.IsInput)
                {
                    int score = bll.GetSetScore(userid, model.ID);
                    //sb.Append("  <div class=\"s_r_sco\">" + score + "_" + Math.Round((decimal)score * model.Scale / 100, 2) + "</div>\r\n");
                    sb.Append("  <div class=\"s_r_sco\">" + Math.Round((decimal)score * model.Scale / 100, 2) + "</div>\r\n");
                    sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                    sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                }
                else
                {
                    if (model.IsCourse)
                    {
                        IList<int> sList = bll.GetUserCourseScore(userid);
                        int totalScore = 0;
                        foreach (int i in sList)
                        {
                            totalScore += i;
                        }
                        //sb.Append("  <div class=\"s_r_sco\">" + totalScore + "_" + Math.Round((decimal)(totalScore) * model.Scale / 50, 2) + "</div>\r\n");
                        sb.Append("  <div class=\"s_r_sco\">" + Math.Round((decimal)(totalScore) * model.Scale / 50, 2) + "</div>\r\n");
                        sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                        sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                    }
                    else
                    {
                        ShortScoreModel ssmodel = bll.GetCertificateScore(userid, areaid);
                        if (ssmodel.ID != -1)
                        {
                            //sb.Append("  <div class=\"s_r_sco\">" + ssmodel.Score + "_" + Math.Round((decimal)(ssmodel.Score) * model.Scale / 100, 2) + "</div>\r\n");
                            sb.Append("  <div class=\"s_r_sco\">" + Math.Round((decimal)(ssmodel.Score) * model.Scale / 100, 2) + "</div>\r\n");
                            sb.Append("  <div class=\"s_r_sd\">" + ssmodel.StartTime.ToString("yyyy.MM.dd") + "</div>\r\n");
                            sb.Append("  <div class=\"s_r_sv\"><a href=\"#?id=\"" + ssmodel.ID + "\"\">查看</a></div>\r\n");
                        }
                        else
                        {
                            sb.Append("  <div class=\"s_r_sco\">0</div>\r\n");
                            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
                            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
                        }
                    }
                }

                sb.Append("</div>\r\n");
            }


            //foreach (KeyValuePair<EnumScoreCategory, string> kvp in scoreList)
            //{
            //    sb.Append("<div class=\"s_rows\">\r\n");
            //    sb.Append("  <div class=\"s_r_sc\">" + kvp.Value + "</div>\r\n");
            //    switch (kvp.Key)
            //    { 
            //        case EnumScoreCategory.OralScore:
            //            sb.Append("  <div class=\"s_r_sco\">" + bll.GetSetScore(userid, kvp.Key) + "</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
            //            break;
            //        case EnumScoreCategory.UsuallyScore:
            //            sb.Append("  <div class=\"s_r_sco\">" + bll.GetSetScore(userid, kvp.Key) + "</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
            //            break;
            //        case EnumScoreCategory.OperationScore:
            //            sb.Append("  <div class=\"s_r_sco\">" + bll.GetSetScore(userid, kvp.Key) + "</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
            //            break;
            //        case EnumScoreCategory.TestScore:
            //            IList<int> sList = bll.GetUserCourseScore(userid);
            //            int totalScore = 0;
            //            foreach (int i in sList)
            //            {
            //                totalScore += i;
            //            }
            //            sb.Append("  <div class=\"s_r_sco\">" + totalScore + "</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
            //            sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
            //            break;
            //        case EnumScoreCategory.CertificateTestScore:
            //            ShortScoreModel model = bll.GetCertificateScore(userid, areaid);
            //            if (model.ID != -1)
            //            {
            //                sb.Append("  <div class=\"s_r_sco\">" + model.Score + "</div>\r\n");
            //                sb.Append("  <div class=\"s_r_sd\">" + model.StartTime.ToString("yyyy.MM.dd") + "</div>\r\n");
            //                sb.Append("  <div class=\"s_r_sv\"><a href=\"#?id=\"" + model.ID + "\"\">查看</a></div>\r\n");
            //            }
            //            else
            //            {
            //                sb.Append("  <div class=\"s_r_sco\">0</div>\r\n");
            //                sb.Append("  <div class=\"s_r_sd\">&nbsp;</div>\r\n");
            //                sb.Append("  <div class=\"s_r_sv\">&nbsp;</div>\r\n");
            //            }
            //            break;
            //        default: break;
            //    }
                sb.Append("</div>\r\n");
            //}
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

